package org.JWCB.friend.mapper.user;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.JWCB.api.domain.judge.vo.UserExeResItem;
import org.JWCB.friend.domain.user.entity.UserSubmit;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface UserSubmitMapper extends BaseMapper<UserSubmit> {
    UserSubmit selectSubmitRes(Long examId, Long questionId, String uniqueId, Long userId);

    /**
     * 查询提交次数最多的题目ID列表
     * 
     * @param limit 限制数量
     * @return 题目ID列表
     */
    @Select("SELECT question_id FROM tb_user_submit GROUP BY question_id ORDER BY COUNT(*) DESC LIMIT #{limit}")
    List<Long> selectHotQuestionIds(Integer limit);

    /**
     * 获取题目的提交次数
     * 
     * @param questionId 题目ID
     * @return 提交次数
     */
    @Select("SELECT COUNT(*) FROM tb_user_submit WHERE question_id = #{questionId} AND exam_id IS NULL")
    Integer selectSubmitCountByQuestionId(Long questionId);
}
